package lab.poc.erl.otp;

public class SupervisorSpec {

	public static enum RestartStrategy {
		/**
		 * Restart the child that has terminated.
		 */
		ONE_FOR_ONE,
		/**
		 * Terminate all children and restart them.
		 */
		ONE_FOR_ALL,
		/**
		 * Terminate all children that were started after the child that crashed
		 * and restart them in the original start order.
		 */
		REST_FOR_ONE
	}

	public static final SupervisorSpec DEFAULT = new SupervisorSpec(
			RestartStrategy.ONE_FOR_ONE, 6, 60);

	public final RestartStrategy restartStrategy;
	public final int maxAllowedRestarts;
	public final long withinSeconds;

	public SupervisorSpec(final RestartStrategy restartStrategy,
			final int maxAllowedRestarts, final long withinSeconds) {
		this.restartStrategy = restartStrategy;
		this.maxAllowedRestarts = maxAllowedRestarts;
		this.withinSeconds = withinSeconds;
	}
}
